<#include "custom.include"> <#assign className = table.className>
<#assign idColumn = table.idColumn ?lower_case> <#assign
classNameLower=className?uncap_first> <#assign
classNameAllLower=className?lower_case>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/jsp/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ include file="/WEB-INF/jsp/common/meta.jsp"%>
<%@ include file="/WEB-INF/jsp/common/title.jsp"%>
<script type="text/javascript">
$(function() {
	var form = $("form[name=listForm]");
	initGrid(form);
	var win = $("#win").window({
		title : "新增",
		modal : true
	});
	var handler = function() {
		var hid = function() {
			//win.window("close");
		};
		$("input[type='button']").click(hid);
	};
	$("#btn_add").click(function() {
		win.window('open');
		$("#msg").load("${"$"}{ctx}/${classNameLower}Controller.do?method=add","",handler); 
});
	$("#btn_modify").click(function() {
		var ids = getSelected(true, form);
		if (ids) {
			win.window('open');
			$("#msg").load("${"$"}{ctx}/${classNameLower}Controller.do?method=modify",{id : ids}, function() {
				operForm = $("form", this); {
					id : ids
				}, handler);
			}
		});
	$("#btn_remove").click(function() {
		var ids = getSelected(false, form);
		if (!ids) return;
		if (!confirm("确定删除选中的记录吗？"))
			return;
		var old = form.attr("action");
		form.attr("action", "${"$"}{ctx}/${classNameLower}Controller.do?method=delete&ids=" + ids);
		submit(form, function(data, status) {
			if (isSuccess(data, status)) {
				alert("删除成功！");
				form.attr("action", old);
				var fn = function() {
					form.submit();
				}
				fn.defer(700);
			} else {
				alert("删除失败！");
			}
		}, function(data, status) {
			alert("删除失败！");
		});
	});
	$("#btn_query").click(function() {
		form.submit();
	});
	$("#container").layout();
	$(window).resize(function() {
		$("#container").layout();
	});
});
</script>
</head>
<body>
	<form method="post" target="_self" action="${"$"}{ctx}/${classNameLower}Controller.do?method=list" name="listForm" style="width: 100%;height: 100%;">
		<div style="position: relative;" id="container" fit="true">
			<div class="datagrid-toolbar" region="north" border="false">
				<div class="tool-btn" id="btn_add">
					<span class="icon-add">&nbsp;</span>
					<fmt:message key="button.add" />
				</div>
				<div class="tool-btn" id="btn_modify">
					<span class="icon-edit">&nbsp;</span>
					<fmt:message key="button.edit" />
				</div>
				<div class="tool-btn" id="btn_remove">
					<span class="icon-remove">&nbsp;</span>
					<fmt:message key="button.remove" />
				</div>
				<div class="tool-btn" id="btn_search">
					<span class="icon-search">&nbsp;</span>
					<fmt:message key="button.query" />
				</div>
			</div>
			<div id="grid-body" class="grid-body" region="center">
	<#--绑定数据--><hih:table items="${r"${list}"}" var="bean">
					<hih:column field="${idColumn}" checkbox="true"/>
	<#--要显示的数据列--> <#list table.columns as column> <#if column._pri="N">
					<hih:column field="${column.columnNameLower}" header="${classNameAllLower}.${column.columnNameLower}" sort="true"/></#if> </#list>
				</hih:table>
			</div>
			<jsp:include page="/WEB-INF/jsp/common/page.jsp" />
		</div>
	</form>
	<div id="win" closed="true" style="width: 450px; height: 350px;" buttons="#buttons">
		<div id="msg"></div>
	</div>
</body>
</html>
